package com.xiaren.ui.edit;

import java.awt.BorderLayout;
import java.awt.HeadlessException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.xiaren.biz.FrameBiz;
import com.xiaren.common.ObjectConstant;

/**
 * @主页 http://www.leaf123.cn/
 * @邮箱 xia5523@qq.com
 */
public class MaxFileFrame extends JFrame {

	TextFile textFile = null;
	JPanel panel = new JPanel();

	public MaxFileFrame(TextFile textFile) throws HeadlessException {
		super();
		this.textFile = textFile;
		init();
	}

	void init(){
		textFile.ifMaxFrame = true;
		panel.setLayout(new BorderLayout());
		panel.add(textFile,BorderLayout.CENTER);
		this.add(panel);
		this.setVisible(true);
		FrameBiz.setLocationCenter(this);
		this.addWindowListener(new WindowAdapter() {

			@Override
			public void windowClosing(WindowEvent e) {
				textFile.ifMaxFrame = false;
				if(textFile.isSave){
					ObjectConstant.mainEdit.add(textFile, textFile.fileName);
				} else {
					textFile.isSave = false;
					ObjectConstant.mainEdit.add(textFile, textFile.fileName + " *");
					ObjectConstant.mainEdit.setSelectedComponent(textFile);
				}
			}

		});

		this.setAlwaysOnTop(true);
	}



}
